package 
{
	import flash.display.MovieClip;
	
	import org.osmf.media.MediaPlayerSprite;
	import org.osmf.net.DynamicStreamingItem;
	import org.osmf.net.DynamicStreamingResource;
	
	//Sets the size of the SWF
	[SWF(width="800", height="600")]
	
	public class DynamicStreamSample extends MovieClip
	{
		import org.osmf.media.MediaPlayerSprite;
		import org.osmf.elements.VideoElement;
		import org.osmf.media.URLResource;
		import org.osmf.utils.URL;
		
		
		////////////////////////////////////////////////////
		//DECLARATIONS
		////////////////////////////////////////////////////
		
		//URI of the media
		
		public var playerSprite:MediaPlayerSprite;
		
		////////////////////////////////////////////////////
		//CONSTRUCTOR
		////////////////////////////////////////////////////
		
		public function DynamicStreamSample()
		{
			initPlayer();
		}
		
		
		
		
		protected function initPlayer():void
		{
			//sprite that contains a MediaPlayer to manage display and control of MediaElements
			playerSprite = new MediaPlayerSprite();
			
			//create the base of the dynamic streaming resource - set the connection uri
			var dynamicStreamResource:DynamicStreamingResource = new DynamicStreamingResource( "rtmp://cp67126.edgefcs.net/ondemand" );
			
			//add the appropriate media to the dynamic streaming resource - path/bitrate/width/height
			dynamicStreamResource.streamItems.push( new DynamicStreamingItem( "mp4:mediapm/ovp/content/demo/video/elephants_dream/elephants_dream_768x428_24.0fps_408kbps", 408, 768, 428 ) );
			dynamicStreamResource.streamItems.push( new DynamicStreamingItem( "mp4:mediapm/ovp/content/demo/video/elephants_dream/elephants_dream_768x428_24.0fps_608kbps", 608, 768, 428 ) );
			dynamicStreamResource.streamItems.push( new DynamicStreamingItem( "mp4:mediapm/ovp/content/demo/video/elephants_dream/elephants_dream_1024x522_24.0fps_908kbps", 908, 1024, 522 ) );
			dynamicStreamResource.streamItems.push( new DynamicStreamingItem( "mp4:mediapm/ovp/content/demo/video/elephants_dream/elephants_dream_1024x522_24.0fps_1308kbps", 1308, 1024, 522 ) );
			dynamicStreamResource.streamItems.push( new DynamicStreamingItem( "mp4:mediapm/ovp/content/demo/video/elephants_dream/elephants_dream_1280x720_24.0fps_1708kbps", 1708, 1280, 720 ) );
			
			//create a video element from the dynamic streaming resource, and set it as the media item for the medoa player sprite
			playerSprite.media = new VideoElement( dynamicStreamResource );
			
			//Adds the sprite to the stage
			addChild( playerSprite );
		}
		
	}
}